package edu.zzuli.model.xt.jqqx.zzjggl;

import java.io.Serializable;

import javax.annotation.Resource;

import org.apache.struts2.ServletActionContext;
import org.springframework.stereotype.Controller;

import edu.zzuli.model.orm.po.GG_JGBH;
import edu.zzuli.model.xt.jqqx.zzjggl.iface.ZzjgglService;

/**
 * @author tianshaojie
 * @date 2011-1-16
 * @discription : 
 */
@SuppressWarnings("serial")
@Controller
public class AddorModZzjgAction implements Serializable{
	
	@Resource
	private ZzjgglService zzjgglService;
	
	private GG_JGBH gg_jgbh;
	
	private GG_JGBH sjjg;
	
	private String ajaxResult;
	
	public String execute() {
		try {
			gg_jgbh.setGG_JGBH(sjjg);
			zzjgglService.saveOrUpdateGG_JGBH(gg_jgbh);
			ajaxResult = "success";
		} catch (Exception e) {
			ajaxResult = "error";
		}
		return ajaxResult;
	}
	
	public String addOrModPage() {
		String id = ServletActionContext.getRequest().getParameter("jgbh");
		if (id != null && !"".equals(id)) {
			gg_jgbh = (GG_JGBH) zzjgglService.selectSinglePO(new GG_JGBH(id));
			this.sjjg = new GG_JGBH(ServletActionContext.getRequest().getParameter("sjjgid"));
			ServletActionContext.getRequest().setAttribute("gg_jgbh", gg_jgbh);
			ServletActionContext.getRequest().setAttribute("sjjg", sjjg);
		} else {
			gg_jgbh = new GG_JGBH();
			this.sjjg = new GG_JGBH(ServletActionContext.getRequest().getParameter("sjjgid"));
			ServletActionContext.getRequest().setAttribute("gg_jgbh", gg_jgbh);
			ServletActionContext.getRequest().setAttribute("sjjg", sjjg);
		}
		return "success";
	}

	public void setAjaxResult(String ajaxResult) {
		this.ajaxResult = ajaxResult;
	}

	public String getAjaxResult() {
		return ajaxResult;
	}
	
	public GG_JGBH getGg_jgbh() {
		return gg_jgbh;
	}

	public void setGg_jgbh(GG_JGBH ggJgbh) {
		gg_jgbh = ggJgbh;
	}

	public void setSjjg(GG_JGBH sjjg) {
		this.sjjg = sjjg;
	}

	public GG_JGBH getSjjg() {
		return sjjg;
	}
}
